<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'privilegePage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=path %>/css/mine.css" type="text/css" rel="stylesheet">
	<link href="<%=path %>/css/custom.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<%=path %>/js/user.js"></script>
	<script type="text/javascript" src="<%=path %>/js/dream_plugins.js"></script>
	<script type="text/javascript" src="<%=path%>/js/jquery-1.8.3.min.js"></script>
	<script language="javascript" src="<%=path %>/js/jquery_treeview/jquery.treeview.js"></script>
	<link type="text/css" rel="stylesheet" href="<%=path %>/js/jquery_treeview/jquery.treeview.css" />
	<script type="text/javascript">
		$(function(){
			// 指定事件处理函数
			$("[name=privilegeIds]").click(function(){
				
				// 当选中或取消一个权限时，也同时选中或取消所有的下级权限
				$(this).siblings("ul").find("input").attr("checked", this.checked);
				
				// 当选中一个权限时，也要选中所有的直接上级权限
				if(this.checked == true){
					$(this).parents("li").children("input").attr("checked", true);
				}
				
			});
		});
	</script>
<style type="text/css">
.privilege{ margin: 0 aotu; width:450px;height: 450px;}
#tree{position: relative;}
</style>
  </head>
  
  <body>
  <div class="div_head">
		<span> <span style="float:left">当前位置是：用户管理  》 角色权限设置&nbsp;  正在为【<span style="color:red;font-weight: bold;">${role.name}</span>】 配置权限 </span>   
			<span style="float:left;margin-right: 8px;font-weight: bold;color:red">&nbsp;&nbsp;注意：修改权限之后将会自动退出登录！</span>
		</span>
	</div>
   <div class="privilege">
    
  <form action="User_updatePrivilege" method="post">
  <input  type="hidden" name="role.id" value="${role.id}"/>
   <ul id="tree"> 
 <s:iterator value="#request.topPrivilegeList">
	<li>
		<input type="checkbox" name="privilegeIds" value="${id}" id="cb_${id}" <s:property value="%{id in privilegeIds ? 'checked' : ''}"/> />
		<label for="cb_${id}"><span class="folder">${name}</span></label>
		<ul>
		<s:iterator value="children">
			<li>
				<input type="checkbox" name="privilegeIds" value="${id}" id="cb_${id}" <s:property value="%{id in privilegeIds ? 'checked' : ''}"/> />
				<label for="cb_${id}"><span class="folder">${name}</span></label>
				<ul>
				<s:iterator value="children">
					<li>
						<input type="checkbox" name="privilegeIds" value="${id}" id="cb_${id}" <s:property value="%{id in privilegeIds ? 'checked' : ''}"/> />
						<label for="cb_${id}"><span class="folder">${name}</span></label>
					</li>
				</s:iterator>
				</ul>
			</li>		
		</s:iterator>
		</ul>
	</li>
</s:iterator>
</ul> 
<input type="submit" name="" value="提交" />&nbsp;
<input type="button" value="返回" onclick="back()">
</form>

 </div>
 
    <script language="javascript">
        	$("#tree").treeview();
        </script>
  </body>
</html>
